import os,sys,uvicorn
import gradio as gr
from fastapi import FastAPI



app = FastAPI()
@app.get("/")
def read_main():
    return {"message": "This is your main app"}
io = gr.Interface(lambda x: "Hello, " + x + "!", "textbox", "textbox")
app = gr.mount_gradio_app(app, io, path="/gradio")

if os.path.exists("ssl/key.pem") and os.path.exists("ssl/cert.pem"):
    uvicorn.run(app, host="0.0.0.0", port=5000,ssl_keyfile="ssl/key.pem",ssl_certfile="ssl/cert.pem")
else:
    uvicorn.run(app, host="0.0.0.0", port=5000)
    
print("Finish!")